package jredis;

import java.util.HashMap;

import org.junit.Test;

import redis.clients.jedis.Jedis;

public class First {
	
	@Test
	public void save() {

		Jedis jedis = new Jedis("172.16.166.2", 6379);
		long start = System.currentTimeMillis();
		for(int i = 0; i < 1000_00; i++){
			
			String str = String.valueOf(i);
			HashMap<String, String> map = new HashMap<>();
			map.put("name", str);
			map.put("age", str);
			jedis.hmset(new StringBuilder("student").append(str).toString(), map);
		}
		long end = System.currentTimeMillis();
		System.out.println(((end - start)/1000.0) + "秒");
	}
	
	@Test
	public void delete() {
		
		Jedis jedis = new Jedis("172.16.166.2", 6379);
		long start = System.currentTimeMillis();
		for(int i = 0; i < 1000_00; i++){
			
			String str = String.valueOf(i);
			jedis.del(new StringBuilder(str).toString());
		}
		long end = System.currentTimeMillis();
		System.out.println(((end - start)/1000.0) + "秒");
	}
}
